const api = require("./interface.js");
const request = require("./http.js");

function Login(){
    return new Promise((resolve, reject)=>{
        wx.login({
            success (res) {
              if (res.code) {
                //发起网络请求
                resolve(request.post(api.common.login, res.code));
              } else {
                reject(res.errMsg);
                console.log('登录失败！' + res.errMsg)
              }
            },
            fail(err){
                reject(err)
            }
        })
    })
}